package lambda.function;

import lambda.entity.User;

import java.util.function.Consumer;

/**
 * @author LIBOFEI
 * @ClassName Consumer
 * @description Consumer 消费型接口 用来消费 T 类型的对象
 * @date 2022/4/6 15:54
 * @Version 1.0
 **/
public class ConsumerTest {


    public static void main(String[] args) {
//        Consumer<String> strC = new Consumer<String>() {
//            @Override
//            public void accept(String o) {
//                System.out.println(o + "LLLL");
//            }
//        };
//        Consumer<String> strC = (x) -> {
//            System.out.println(x + "LLLL");
//        };

//        String s = consumerTest(strC, "你好，我是不达意");
//        System.out.println(s);

        Consumer<User> userC = (user) -> {
            user.setName("11111");
            user.setId(111);
        };
        User user = new User();
        consumerTest(userC,user);
        System.out.println(user);
    }


//    public static <T> T consumerTest(Consumer<T> consumer,T str){
//        consumer.accept(str);
//        return str;
//    }


    public static void consumerTest(Consumer consumer, User user){
        consumer.accept(user);
    }
}
